<%--
  Created by IntelliJ IDEA.
  User: Mr.G
  Date: 2018/12/29
  Time: 19:24
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <title>Title</title>
</head>
<body>
<form class="layui-form" action="" lay-filter="Reservleform" id="Reservleform">
    <table class="layui-table">
        <tbody>
        <tr>
            <%--查询的id--%>
            <input type="hidden" id="yuanid" name="yuanid">
            <%--挂号费--%>
            <input type="hidden" id="registryFee" name="registryFee">
            <%--预约id--%>
            <input type="hidden" name="reserveId" id="reserveId">
            <%--状态--%>
            <input type="hidden" name="isDiagnosis" value="1">
            <td>手机号:</td>
            <td><input type="text" id="reserveMobile" name="reserveMobile" class="layui-input"></td>
            <td>身份证号:</td>
            <td><input type="text" id="reserveshenfen" name="reserveshenfen" class="layui-input"></td>
            <td>会员卡号:</td>
            <td><input type="text" id="membershipCardNo" name="membershipCardNo" class="layui-input"></td>
        </tr>
        <tr>
            <td>病历号:</td>
            <td><input type="text" id="medicalRecordNo" name="medicalRecordNo" class="layui-input">
                <select name="medicalRecordNo2" id="medicalRecordNo2" lay-search  lay-filter="binglihao">
                    <option value="-1">请选择预约号</option>
                </select>
            </td>
            <td>患者姓名:</td>
            <td><input type="text" id="reserveName" name="reserveName" class="layui-input"></td>
            <td>性别:</td>
            <td>
                <input type="radio" name="reserveSex" value="男" title="男" checked>
                <input type="radio" name="reserveSex" value="女" title="女">
            </td>
        </tr>

        <tr>
            <td>挂号医师:</td>
            <td>
                <select  name="userId" id="userId" lay-filter="yisheng">
                    <option value="0">请选择</option>
                </select>
            </td>
            <td>就诊时间:</td>
            <td><input type="text" name="reserveopentime" id="reserveopentime" lay-verify="date" placeholder="H点m分" autocomplete="off" class="layui-input"></td>
            <td>至</td>
            <td><input type="text" name="reserveopencole" id="reserveopencole" lay-verify="date2" placeholder="H点m分" autocomplete="off" class="layui-input"></td>
        </tr>
        <tr>
            <td>备注:</td>
            <td colspan="5"><textarea name="memo" id="memo" required lay-verify="required" placeholder="请输入" class="layui-textarea"></textarea></td>
        </tr>
        </tbody>
    </table>
</form>
<script>
        var form = layui.form;
        var laydate = layui.laydate;
        //时间选择
        laydate.render({
            elem: '#reserveopentime'
            ,type: 'time'
        });
        laydate.render({
            elem: '#reserveopencole'
            ,type: 'time'
        });

        //取出医生数据
        $.get("${path}/yuyuedengji/yishengList",function(data){
            // console.log(data)
            $.each(data,function(){
                var opt = $("<option></option>").appendTo("#userId");
                opt.text(this.username).val(this.userid);
            });
            layui.form.render()
        });

        //取出预约数据
        $.get("${path}/jiuzhen/yuyueList",function(data){
            // console.log(data)
            $.each(data,function(){
                var opt = $("<option></option>").appendTo("#medicalRecordNo2");
                opt.text(this.medicalRecordNo).val(this.reserveId);
            });
            layui.form.render()
        });

        //监听选择医生下拉框
        form.on('select(binglihao)', function(data){
            // console.log(data.value); //得到被选中的值

            $.get("${path}/jiuzhen/get",{binglihao:data.value},function (getstr) {
                setTimeout(function () {
                    getstr["yuanid"] = getstr.reserveId;
                    form.val('Reservleform',getstr);
                },100)
            })

        });



    $(function () {
        //获取病历号
        $.get("${path}/yuyuedengji/maxnum",function (maxnum) {
            var binghao = parseInt(maxnum)+1;
            $("#binglihao").text(binghao)
        })
    })
</script>
</body>
</html>
